﻿using University.Workshop.Business;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using University.Workshop.Model;
using System.Data;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for AgendaManagerTest and is intended
    ///to contain all AgendaManagerTest Unit Tests
    ///</summary>
    ///



    [TestClass()]
    public class AgendaManagerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for NewAppointment
        ///</summary>
        ///

        private Appointment LoadAppointment()
        {
            Random random = new Random(DateTime.Now.Millisecond);
            Appointment appointment = new Appointment();
            //agenda.CIDoctor = "6600234";
            appointment.CIPatient = "5736789";
            appointment.DateAppointment = DateTime.Today.ToShortDateString();
            appointment.TimeAppointment = "09:0"+random.Next(10);
            appointment.StateAppointment = "Confirmado";
            return appointment;
        }

        /// <summary>
        ///A test for InsertNewUser
        ///</summary>

        [TestMethod()]
        public void NewAppointmentTest()
        {
            Appointment appointment = LoadAppointment(); // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = AgendaManager.NewAppointment(appointment);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for InsertNewUser Null
        ///</summary>

        [TestMethod()]
        public void NewAppointmentNullTest()
        {
            Appointment appointment = null; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = AgendaManager.NewAppointment(appointment);
            Assert.AreEqual(expected, actual);            
        }

        /// <summary>
        ///A test for LoadDataGridViewHorary
        ///</summary>
        [TestMethod()]
        public void LoadDataGridViewHoraryTest()
        {
            string dateTime = "5/10/2012";
            DataTable actual;
            actual = AgendaManager.LoadDataGridViewHorary(dateTime, "6600234");
            Assert.IsTrue(actual.Rows.Count >= 1);            
        }

        /// <summary>
        ///A test for LoadDataAppointmentsForToday
        ///</summary>
        [TestMethod()]
        public void LoadDataAppointmentsForTodayTest()
        {
            DataTable actual;
            actual = AgendaManager.LoadDataAppointmentsForToday();
            Assert.IsFalse(actual.Rows.Count >= 1);
        }
        /// <summary>
        ///A test for ModifyAppointment
        ///</summary>
        [TestMethod()]
        public void ModifyAppointmentTest()
        {
            Appointment appointment = new Appointment();//LoadAgenda(); // TODO: Initialize to an appropriate value
            string idAgenda = "6733999"; // TODO: Initialize to an appropriate value
            appointment.DateAppointment = DateTime.Today.ToShortDateString();
            appointment.StateAppointment = "Cancelado";
            appointment.TimeAppointment = "11:00";
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = AgendaManager.ModifyAppointment(appointment, idAgenda);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for null ModifyAppointment
        ///</summary>
        [TestMethod()]
        public void ModifyAppointmentTestNull()
        {
            Appointment appointment = null; // TODO: Initialize to an appropriate value
            string idAppointment = string.Empty; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = AgendaManager.ModifyAppointment(appointment, idAppointment);
            Assert.AreEqual(expected, actual);           
        }
    }
}
